package com.future.hedongjun.mine.adapter;

import android.graphics.Color;
import android.support.annotation.Nullable;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.future.hedongjun.R;
import com.future.hedongjun.common.PriceHelper;
import com.future.hedongjun.mine.bean.ClassOrderItem;

import java.util.List;

/**
 * @author jniu
 * @Email niuxiaoqi@hztianque.com
 * @time 2018/12/30
 */
public class ClassOrderAdapter extends BaseQuickAdapter<ClassOrderItem,BaseViewHolder> {

    private final int colorRed;
    private final int colorGray;

    public ClassOrderAdapter(@Nullable List<ClassOrderItem> data) {
        super(R.layout.item_class_order, data);
        colorRed = Color.parseColor("#FF262C");
        colorGray = Color.parseColor("#999999");
    }

    @Override
    protected void convert(BaseViewHolder helper, ClassOrderItem item) {
        helper.setText(R.id.tv_order_id,"订单编号:"+item.getOrder_num());
        helper.addOnClickListener(R.id.item_btn);
        switch (item.getStatus()) {
            case 1:
                helper.setText(R.id.tv_type,"待支付");
                helper.setVisible(R.id.item_btn,true);
                helper.setTextColor(R.id.tv_type,colorRed);
                break;
            case 2:
                helper.setText(R.id.tv_type,"已取消");
                helper.setVisible(R.id.item_btn,false);
                helper.setTextColor(R.id.tv_type,colorGray);
                break;
            case 3:
                helper.setText(R.id.tv_type,"已完成");
                helper.setVisible(R.id.item_btn,false);
                helper.setTextColor(R.id.tv_type,colorGray);
                break;
        }

//        helper.setTextColor(R.id.tv_type,);
        Glide.with(mContext).load(item.getLogo_img()).into((ImageView) helper.getView(R.id.item_iv_1));
        helper.setText(R.id.tv_name,item.getName());
        helper.setText(R.id.tv_price,PriceHelper.priceFormat(item.getAmount()));

    }
}
